package cn.bkrc.RedisTest;

import cn.bkrc.redis.RedisListUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class ListTest {
    @Autowired
    RedisListUtils redisListUtil;
    @Test
    public void testRangeList(){
        List<Object> names= redisListUtil.rangeList("countries",0,48);
        System.out.println(names);
    }

    @Test
    public void testPushList(){
        redisListUtil.pushList("countries","china");
    }

    @Test
    public void testPushAllList(){
        List<String> countries=new ArrayList<>();
        countries.add("usa");
        countries.add("canada");
        //redisListUtil.pushAllList("countries",countries);
        //redisListUtil.pushAllList("countries",countries.toArray());
        redisListUtil.pushAllList("countries","jpan","china","usa");
    }

    @Test
    public void testSetList(){
        redisListUtil.setList("countries",0l,"japan");
    }

    @Test
    public void testDeleteList(){
        redisListUtil.deleteList("countries",1l,"japan");
    }
}
